#ifndef __OBDSTN1100_H__
#define __OBDSTN1100_H__

extern const int rxbuf_size;

/********** UART Config *********/
extern void ConfigOBDPort(int fd);


/********** AT Commands *********/

/*<----- General Commands ----->*/
extern int AT_Repeat(int fd, char *rxbuf);
extern int AT_Set_BRD(int fd,char *rxbuf, unsigned char val);
extern int AT_Set_BRT(int fd,char *rxbuf, unsigned char val);
extern int AT_Defaults(int fd, char *rxbuf);
extern int AT_Set_Echo(int fd,char *rxbuf, unsigned char val);
extern int AT_Get_Version(int fd, char *rxbuf);
extern int AT_Set_Linefeeds(int fd,char *rxbuf, unsigned char val);
extern int AT_EnterLowPower(int fd, char *rxbuf);
extern int AT_Set_Memory(int fd,char *rxbuf, unsigned char val);
extern int AT_WarmStart(int fd, char *rxbuf);
extern int AT_Reset(int fd, char *rxbuf);
extern int AT_Get_Description(int fd, char *rxbuf);
extern int AT_Get_Identifier(int fd, char *rxbuf);
extern int AT_Set_Identifier(int fd, char *rxbuf,char *info);

/*<----- Programmable Parameter Commands ----->*/
extern int AT_Set_PP_OFF(int fd,char *rxbuf,char pp);
extern int AT_PP_OFF(int fd, char *rxbuf);
extern int AT_Set_PP_ON(int fd,char *rxbuf,char pp);
extern int AT_PP_ON(int fd,char *rxbuf);
extern int AT_Set_PP_VAL(int fd,char *rxbuf, unsigned char pp,unsigned char val);
extern int AT_Get_PPSummary(int fd, char *rxbuf);

/*<----- Voltage Reading Commands ----->*/
extern int AT_Set_CV(int fd,char *rxbuf,int val);
extern int AT_Get_Voltage(int fd,char *rxbuf);

/*<----- Other Commands ----->*/
extern int AT_Get_Sleep(int fd,char *rxbuf);

/*<----- OBD Commands ----->*/
extern int AT_AllowLong(int fd, char *rxbuf);
extern int AT_AutoReceive(int fd, char *rxbuf);
extern int AT_Set_ADTiming(int fd,char *rxbuf, unsigned char val);
extern int AT_BypassInit(int fd, char *rxbuf);
extern int AT_Get_Protocol(int fd, char *rxbuf);
extern int AT_Get_ProtocolNumber(int fd, char *rxbuf);
extern int AT_Set_Header(int fd,char *rxbuf, unsigned char val);
extern int AT_MonitorAll(int fd, char *rxbuf);
extern int AT_Set_MonitorRev(int fd,char *rxbuf,int val);
extern int AT_Set_MonitorTran(int fd,char *rxbuf,int val);
extern int AT_NormalLength(int fd, char *rxbuf);
extern int AT_ProtocolClose(int fd, char *rxbuf);
extern int AT_Set_Responses(int fd,char *rxbuf, unsigned char val);
extern int AT_Set_RevAddress(int fd,char *rxbuf,int val);
extern int AT_Set_Space(int fd,char *rxbuf, unsigned char val);
extern int AT_Set_HeaderValue_A(int fd,char *rxbuf,int val);
extern int AT_Set_HeaderValue_B(int fd,char *rxbuf,unsigned char val1,unsigned char val2,unsigned char val3);
extern int AT_Set_Protocol(int fd,char *rxbuf, unsigned char val);
extern int AT_Set_ProtocolAuto(int fd,char *rxbuf, unsigned char val);
extern int AT_Set_Timeout(int fd,char *rxbuf, unsigned char val);
extern int AT_Try_Protocol(int fd,char *rxbuf, unsigned char val);
extern int AT_Try_ProtocolAuto(int fd,char *rxbuf, unsigned char val);

/*<----- J1850 Specific Commands ----->*/
extern int AT_Set_IFR(int fd, char *rxbuf,unsigned char val);
extern int AT_Set_IFR_Source(int fd, char *rxbuf,unsigned char val);

/*<----- ISO Specific Commands ----->*/
extern int AT_ISO_Set_BDR_10(int fd, char *rxbuf);
extern int AT_ISO_Set_BDR_96(int fd, char *rxbuf);
extern int AT_ISO_Set_InitAddr(int fd,char *rxbuf, unsigned char val);
extern int AT_ISO_Get_Keyword(int fd, char *rxbuf);
extern int AT_ISO_Set_Keyword(int fd,char *rxbuf,unsigned char val);
extern int AT_ISO_Set_WakeupInterval(int fd,char *rxbuf, unsigned char val);
extern int AT_ISO_Set_WakeupMSG(int fd, char *rxbuf,unsigned char *info,int size);
extern int AT_ISO_Set_AutoFormat(int fd, char *rxbuf,unsigned char val);
extern int AT_ISO_Set_Filter_A(int fd,char *rxbuf,int val);
extern int AT_ISO_Set_Filter_B(int fd,char *rxbuf,unsigned char val1,unsigned char val2,unsigned char val3,unsigned char val4);
extern int AT_ISO_Set_FlowControl(int fd, char *rxbuf,unsigned char val);
extern int AT_ISO_Set_Mask_A(int fd,char *rxbuf,int val);
extern int AT_ISO_Set_Mask_B(int fd,char *rxbuf,unsigned char val1,unsigned char val2,unsigned char val3,unsigned char val4);
extern int AT_ISO_Set_Priority(int fd,char *rxbuf, unsigned char val);
extern int AT_ISO_Set_RevAddr_A(int fd,char *rxbuf,int val);
extern int AT_ISO_Set_RevAddr_B(int fd,char *rxbuf,unsigned char val1,unsigned char val2,unsigned char val3,unsigned char val4);
extern int AT_ISO_Get_StatusCounts(int fd, char *rxbuf);
extern int AT_ISO_Set_DLCDisplay(int fd, char *rxbuf,unsigned char val);
extern int AT_ISO_Set_FC_mode(int fd,char *rxbuf, unsigned char val);
extern int AT_ISO_Set_FCHeader_A(int fd,char *rxbuf,int val);
extern int AT_ISO_Set_FCHeader_B(int fd,char *rxbuf,unsigned char val1,unsigned char val2,unsigned char val3,unsigned char val4);
extern int AT_ISO_Set_FCData(int fd, char *rxbuf,unsigned char *info,int size);
extern int AT_ISO_SendRTR(int fd, char *rxbuf);
extern int AT_ISO_Set_DLCUse(int fd, char *rxbuf,unsigned char val);


/*<----- J1939 CAN Specific Commands ----->*/
extern int AT_Get_DM1(int fd, char *rxbuf);
extern int AT_Set_ELM(int fd, char *rxbuf);
extern int AT_Set_SAE(int fd, char *rxbuf);
extern int AT_Set_PGNMonitor_A(int fd,char *rxbuf,unsigned char val1,unsigned char val2);
extern int AT_Set_PGNMonitor_B(int fd,char *rxbuf,unsigned char val1,unsigned char val2,unsigned char val3);


/********** ST Commands *********/

/*<----- General ----->*/
extern int ST_Set_BRD_Software(int fd,char *rxbuf,long val);
extern int ST_Set_BRT(int fd,char *rxbuf,unsigned int val);
extern int ST_Set_Description(int fd, char *rxbuf,char *info);
extern int ST_Set_DeviceID(int fd, char *rxbuf,char *info);
extern int ST_Set_BRD_Terminal(int fd,char *rxbuf,long val);
extern int ST_Set_BRtoNVM(int fd, char *rxbuf);


/*<----- Device ID ----->*/
extern int ST_Get_DeivceID(int fd, char *rxbuf);
extern int ST_Get_FirmwareID(int fd, char *rxbuf);
extern int ST_Get_ManufactureID(int fd, char *rxbuf);
extern int ST_Get_SerialNum(int fd, char *rxbuf);


/*<----- PowerSave ----->*/
extern int ST_Get_PowerSaveConfig(int fd, char *rxbuf);
extern int ST_EnterSleep(int fd,char *rxbuf,long val);
extern int ST_Get_LastSWTrigger(int fd, char *rxbuf);
extern int ST_Set_Output_Polarity(int fd,char *rxbuf, unsigned char val);
extern int ST_Set_UartSW_Trigger(int fd,char *rxbuf, unsigned char sleep,unsigned char wake);
extern int ST_Set_UartInactivityTimeout(int fd,char *rxbuf,unsigned int val);
extern int ST_Set_UartWakeTiming(int fd,char *rxbuf,unsigned int min,unsigned int max);
extern int ST_Set_ExternalSW_Trigger(int fd,char *rxbuf, unsigned char sleep,unsigned char wake);
extern int ST_Set_ExternalPolarity(int fd,char *rxbuf, unsigned char val);
extern int ST_Get_ExternalStatus(int fd, char *rxbuf);
extern int ST_Set_MinActiveTime(int fd,char *rxbuf,unsigned int val);
extern int ST_Set_MinInactiveTime(int fd,char *rxbuf,unsigned int val);


/*<----- ISO Specific ----->*/
extern int ST_ISO_Set_MaxTiming(int fd,char *rxbuf, unsigned char val);
extern int ST_ISO_Set_BR(int fd,char *rxbuf,long val);
extern int ST_ISO_Set_ManChecksum(int fd,char *rxbuf, unsigned char val);
extern int ST_ISO_Set_MaxtimeRev(int fd,char *rxbuf,unsigned int val);
extern int ST_ISO_Set_TimeTransmit(int fd,char *rxbuf,unsigned int val);


/*<----- CAN Specific ----->*/
extern int ST_Set_FlowControl(int fd,char *rxbuf,int txid,int rxid);
extern int ST_ClearFlowControl(int fd, char *rxbuf);


/*<----- Monitoring ----->*/
extern int ST_Monitor(int fd, char *rxbuf);
extern int ST_MonitorAll(int fd, char *rxbuf);


/*<----- Filtering ----->*/
extern int ST_AddPassFilter(int fd,char *rxbuf,long pattern,long mask);
extern int ST_AddBlockFilter(int fd,char *rxbuf,long pattern,long mask);
extern int ST_AddFCFilter(int fd,char *rxbuf,long pattern,long mask);



extern int ST_ClearPassFilters(int fd, char *rxbuf);
extern int ST_ClearBlockFilters(int fd, char *rxbuf);
extern int ST_ClearFCFilters(int fd, char *rxbuf);

#endif
